﻿@model IEnumerable<QuanLyCayXanh.Models.Address>

@{
    ViewBag.Title = "Index";
}

<h2>Danh sách địa chỉ</h2>

<p>
    @Html.ActionLink("Thêm mới địa chỉ", "Create", null, new {@class="pure-button" })
</p>
<table class="pure-table pure-table-bordered">
    <thead>
        <tr>

            <th>STT</th>
            <th>
                @Html.DisplayNameFor(model => model.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Street.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Ward.Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Ward.District.Name)
            </th>            
            <th></th>
        </tr>
    </thead>
    
    @{
        int count = 0;

    }
    @foreach (var item in Model)
    {
        count = count + 1;
        string trClass = count % 2 == 1 ? "" : "pure-table-odd";
        <tr class="@trClass">
        <td>@count</td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Street.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Ward.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Ward.District.Name)
            </td>            
            
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                @Html.ActionLink("Details", "Details", new { id = item.Id }, new { @class = "detail-link" }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Id }, new { @class = "delete-link", name = item.Name })
            </td>
            
        </tr>
    }

</table>
@Html.Partial("~/Views/Shared/_ActionForm.cshtml")
